#!/usr/bin/env python
from google.appengine.api import users

def getViewVals():
    user = users.get_current_user()
    viewVals = {}
    if user:
        viewVals['email'] = user.email()
        viewVals['signOut'] = users.create_logout_url("/login")
    else:
        viewVals['login'] = users.create_login_url("/login")
        viewVals['subscribe'] =login2Subscribe(viewVals['login'])
    return viewVals
            
def getEmail():
    user = users.get_current_user()
    if user:
        return user.email()
    else:
        return False
    
def login2Subscribe(link):
    return link.replace('https://www.google.com/accounts/ServiceLogin', 'https://accounts.google.com/NewAccount').replace('passive=true', '')
    